// stylelint-disable selector-max-specificity

// Needs refactoring
// Sub nav
.subnav {
  // stylelint-disable-next-line primer/spacing
  margin-bottom: 20px;

  @include clearfix();
}

.subnav-bordered {
  // stylelint-disable-next-line primer/spacing
  padding-bottom: 20px;
  // stylelint-disable-next-line primer/borders, primer/colors
  border-bottom: $border-width $border-style var(--borderColor-muted, var(--color-border-muted));
}

.subnav-flush {
  margin-bottom: 0;
}

.subnav-item {
  position: relative;
  float: left;
  // stylelint-disable-next-line primer/spacing
  padding: 5px var(--base-size-16);
  // stylelint-disable-next-line primer/typography
  font-weight: $font-weight-semibold;
  // stylelint-disable-next-line primer/typography
  line-height: 20px;
  color: var(--fgColor-default, var(--color-fg-default));
  // stylelint-disable-next-line primer/borders, primer/colors
  border: $border-width $border-style var(--control-borderColor-rest, var(--color-border-default));

  + .subnav-item {
    // stylelint-disable-next-line primer/spacing
    margin-left: -1px;
  }

  &:hover,
  &:focus {
    text-decoration: none;
    background-color: var(--bgColor-muted, var(--color-canvas-subtle));
  }

  &.selected,
  &[aria-selected='true'],
  &[aria-current]:not([aria-current='false']) {
    z-index: 2;
    color: var(--fgColor-onEmphasis, var(--color-fg-on-emphasis));
    background-color: var(--bgColor-accent-emphasis, var(--color-accent-emphasis));
    border-color: var(--borderColor-accent-emphasis, var(--color-accent-emphasis));

    // fallback :focus state
    &:focus {
      @include focusOutlineOnEmphasis;

      // remove fallback :focus if :focus-visible is supported
      &:not(:focus-visible) {
        outline: solid 1px transparent;
        box-shadow: none;
      }
    }

    // default focus state
    &:focus-visible {
      @include focusOutlineOnEmphasis;
    }
  }

  &:first-child {
    // stylelint-disable-next-line primer/borders
    border-top-left-radius: $border-radius;
    // stylelint-disable-next-line primer/borders
    border-bottom-left-radius: $border-radius;
  }

  &:last-child {
    // stylelint-disable-next-line primer/borders
    border-top-right-radius: $border-radius;
    // stylelint-disable-next-line primer/borders
    border-bottom-right-radius: $border-radius;
  }
}

.subnav-search {
  position: relative;
  // stylelint-disable-next-line primer/spacing
  margin-left: 12px;
}

.subnav-search-input {
  width: 320px;
  padding-left: var(--base-size-32);
  color: var(--fgColor-muted, var(--color-fg-muted));
}

.subnav-search-input-wide {
  // stylelint-disable-next-line primer/responsive-widths
  width: 500px;
}

.subnav-search-icon {
  position: absolute;
  // stylelint-disable-next-line primer/spacing
  top: 9px;
  left: var(--base-size-8);
  display: block;
  color: var(--fgColor-muted, var(--color-fg-muted));
  text-align: center;
  pointer-events: none;
}

.subnav-search-context {
  .btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    &:hover,
    &:focus,
    &:active,
    &.selected {
      z-index: 2;
    }
  }

  + .subnav-search {
    // stylelint-disable-next-line primer/spacing
    margin-left: -1px;

    .subnav-search-input {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }
  }

  .select-menu-modal-holder {
    z-index: 30;
  }

  .select-menu-modal {
    width: 220px;
  }

  .select-menu-item-icon {
    color: inherit;
  }
}

.subnav-spacer-right {
  // stylelint-disable-next-line primer/spacing
  padding-right: 12px;
}
